#pragma once

#include "GLPrimitives.h"
#include "UIElement.h"
#include "Globals.hpp"
#include "ClippingPlane.h"
#include <fstream>
#include <string>

using namespace std;

class Button : public UIElement
{
private:
	string text;	// The button text
	int x1, x2, y1, y2;	// Button coordinates
	SDL_Rect rect;

	string m_name, m_mouseover_name; // Used for getting different ID tags from Entity

	bool drawBox;

public:
	

	Button();
	~Button();

	const char* GetText() const {return text.c_str();}
	void SetText(string message) {text = message;}

	int GetX1() const {return x1;}
	int GetX2() const {return x2;}
	int GetY1() const {return y1;}
	int GetY2() const {return y2;}
	int GetMidY(const float& fontSize) const {return (int)((y1 + y2) / 2) - ((int)fontSize / 2);}	// Used to display the text in the "middle" of a button
	int GetMidX(const float& fontSize) const {return (int)((x1 + x2) / 2) - ((text.length() * ((int)fontSize / 2)) / 2);}  // Centers text in the x plane of button

	void Load_Button(const char* filename, string name, string mouseover_name);
	bool inBounds( int x, int y );  // Check to see if a click is in bounds, also changes mouseover graphics

	void SetXY(const int& X1, const int& Y1, const int& X2, const int& Y2) {x1 = X1; y1 = Y1; x2 = X2; y2 = Y2; ChangeX(X1); ChangeY(Y1);
	rect.x = x1; rect.y = y1; rect.w = x2 - x1; rect.h = y2 - y1;} // funky but it works
	//void SetXY(int X1, int Y1, int X2, int Y2) {x1 = X1; x2 = X2; y1 = Y1; y2 = Y2; ChangeX(X1); ChangeY(Y1);}

	void SetImages(string ID, string mouseOverID) {m_name = ID; m_mouseover_name = mouseOverID; SetImageID(m_name);}  // Don't use this.
	void SetMouseOverGraphic() {SetImageID(m_mouseover_name);}
	void SetNameGraphic() {SetImageID(m_name);}

	void DrawBox();
	bool GetDrawBox() {return drawBox;}
	void SetDrawBox(bool value) {drawBox = value;}

	void Update();
};